import { NgModule } from '@angular/core';
import { RouterModule, NavigationEnd, Router } from '@angular/router';
import { GeneralToolingComponent } from './general-tooling/general-tooling.component';
import { DedicatedToolingComponent } from './dedicated-tooling/dedicated-tooling.component';
import { FinancialCostToolingsComponent } from './financial-cost-toolings/financial-cost-toolings.component';
import { ToolingRepairComponent } from './tooling-repair/tooling-repair.component';
import { ToolingIdentifyComponent } from './tooling-identifies/tooling-identify.component';

@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                children: [
                    { path: 'general-tooling', component: GeneralToolingComponent },
                    { path: 'dedicated-tooling', component: DedicatedToolingComponent },
                    { path: 'financial-cost-toolings', component: FinancialCostToolingsComponent },
                    { path: 'tooling-repair', component: ToolingRepairComponent },
                    { path: 'tooling-identifies', component: ToolingIdentifyComponent }
                ]
            }
        ])
    ],
    exports: [RouterModule]
})
export class ToolingsRoutingModule {
    constructor(private router: Router) {
        router.events.subscribe(event => {
            if (event instanceof NavigationEnd) {
                window.scroll(0, 0);
            }
        });
    }
}
